package work

import (
	"parking-lot-go-admin/controller"
	"parking-lot-go-admin/model"
	"parking-lot-go-admin/model/work"
	"time"

	"github.com/gin-gonic/gin"
)

func Reply(c *gin.Context) {
	requestDataStruct := struct {
		Id     int    `json:"id"`
		Answer string `json:"answer"`
		Remark string `json:"remark"`
	}{}

	c.ShouldBindJSON(&requestDataStruct)

	var workOrderStruct work.WorkOrderStruct

	model.UpdateModelData(
		model.Db,
		workOrderStruct.TableName(),
		map[string]interface{}{
			"id": requestDataStruct.Id,
		},
		map[string]interface{}{
			"answer":          requestDataStruct.Answer,
			"remark":          requestDataStruct.Remark,
			"status":          1,
			"answer_admin_id": 1,
			"handle_at":       time.Now(),
		},
	)

	controller.Success(c, "")
}
